//
//  OnlineDetailModel.m
//  XiXi
//
//  Created by HawkingWang on 16/10/18.
//  Copyright © 2016年 xi-xi.cc. All rights reserved.
//

#import "OnlineDetailModel.h"

@implementation OnlineDetailModel

-(OnlineDetailModel *) initModel:(NSDictionary *)dic{
    if(self){
        self.unique_id = dic[@"schedule"][@"id"];
        self.threater_id = dic[@"schedule"][@"threater_id"];
        self.hall_id = dic[@"schedule"][@"hall_id"];
        self.opera_id = dic[@"schedule"][@"opera_id"];
        self.threater_name = dic[@"threater"][@"name"];
        self.address = dic[@"threater"][@"address"];
        self.hall_name = dic[@"hall"][@"name"];
        self.opera_name = dic[@"opera_name"];
        
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
        [dateFormatter setTimeZone:timeZone];
        [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
        [dateFormatter setDateFormat:@"yyyy.MM.dd HH:mm"];
        
        NSTimeInterval startTimeInterval = [dic[@"schedule"][@"start_time"] doubleValue];
        NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:startTimeInterval];
        NSString *startDateStr = [dateFormatter stringFromDate:startDate];
        self.start_time = startDateStr;
        
        [dateFormatter setDateFormat:@"HH:mm"];
        NSTimeInterval endTimeInterval = [dic[@"schedule"][@"end_time"] doubleValue];
        NSDate *endDate = [NSDate dateWithTimeIntervalSince1970:endTimeInterval];
        NSString *endDateStr = [dateFormatter stringFromDate:endDate];
        self.end_time = endDateStr;
        
        self.time = [NSString stringWithFormat:@"%@ ~ %@", self.start_time, self.end_time];
        
        self.could_check = [NSString stringWithFormat:@"%@", dic[@"could_check"]];
    }
    return self;
}
+(OnlineDetailModel *) initWithDic:(NSDictionary *)dic
{
    OnlineDetailModel *model = [[OnlineDetailModel alloc]init];
    return [model initModel:dic];
}


@end
